import Data.Bits
import Data.Word
import Control.Monad

flippingBits :: Word32 -> Word32
flippingBits = complement

main = do
    q <- readLn
    xs <- replicateM q getLine
    mapM_ (putStrLn . show . flippingBits . read) xs